<?php

class TPEnum
{
    const Value = 0; //值
    const Caption = 1; //显示内容
    const Append1 = 2; //备注1
    const Append2 = 3; //备注2
    const Append3 = 4; //备注3
    const Append4 = 5; //备注4
    const Append5 = 6; //备注5

    public $EnumTypes = array();

    /**
     * [show 通过value获取当前枚举]
     * @Description 通过value获取当前枚举
     * @Author      FengPQ
     * @DateTime    2020-05-15T00:12:04+0800
     * @param       [type]                   $v [value数据]
     * @return      [type]                      [枚举值]
     */
    public function show($v)
    {
        $ret = $this->getByValue($v);
        if ($ret) {
            return $ret[self::Caption];
        }
        return '';
    }

    /**
     * [getAll 获取当前枚举所有值]
     * @Description 获取当前枚举所有值
     * @Author      FengPQ
     * @DateTime    2020-05-15T00:13:04+0800
     * @return      [type]                   [当前枚举数组]
     */
    public function getAll()
    {
        return $this->EnumTypes;
    }

    public function getByValue($v)
    {
        $ret = false;
        foreach ($this->EnumTypes as $temp) {
            if ($temp[self::Value] == $v) {
                $ret = $temp;
                break;
            }
        }
        return $ret;
    }

    /**
     * [getCaptions 获取caption数组]
     * @Description 获取caption数组
     * @Author      FengPQ
     * @DateTime    2020-05-15T00:15:43+0800
     * @return      [type]                   [description]
     */
    public function getCaptions()
    {
        $new_array = array();
        foreach ($this->EnumTypes as $k => $v) {
            $new_array[] = $v[self::Caption];
        }
        return $new_array;
    }

}

//有效状态
class EnableState extends TPEnum
{
    const Enable = array("1", '启用');
    const Disable = array("0", '禁用');

    function __construct()
    {
        $this->EnumTypes = array(self::Enable, self::Disable);
    }
}

//删除状态
class DeleteState extends TPEnum
{
    const Delete = array("1", '已删除');
    const UnDelete = array("0", '未删除');

    function __construct()
    {
        $this->EnumTypes = array(self::Delete, self::UnDelete);
    }
}

//审核状态
class AuditState extends TPEnum
{
    const UnAudit = array("0", '审核中', '#8E8E8B');
    const Pass = array("1", '已通过', '#27A51A');
    const Refused = array("2", '已拒绝', '#dd2727');
    const Backout = array("3", '已撤销', '#FF9806');

    function __construct()
    {
        $this->EnumTypes = array(self::UnAudit, self::Pass, self::Refused, self::Backout);
    }
}

//文件类型
class DocumentType extends TPEnum
{
    const Excel = array("1", array('xls', 'xlsx'), 'excel.png');
    const Pdf = array("2", array('pdf'), 'pdf.png');
    const Word = array("3", array('docx', 'doc'), 'word.png');
    const Img = array("4", array('png', 'jpg', 'jpeg', 'gif'), 'img.png');
    const Ppt = array("5", array('ppt', 'pptx'), 'ppt.png');
    const Text = array("6", array('txt'), 'text.png');
    const Php = array("7", array('php'), 'php.png');

    function __construct()
    {
        $this->EnumTypes = array(self::Excel, self::Pdf, self::Word, self::Img, self::Ppt, self::Text, self::Php);
    }
}

//用户类型
class AccountType extends TPEnum
{
    const Admin = array("1", 'Admin用户');
    const Cust = array("2", 'Cust用户');

    function __construct()
    {
        $this->EnumTypes = array(self::Admin, self::Cust);
    }
}

//设备类型，securityservice中的source
//append1,access token 时长；append2，refresh token 时长
class DeviceType extends TPEnum
{
    const PC = array("1", 'PC端口', '604800', '2592000'); //access token 7天; refreshToken 30天
    const H5 = array("2", 'H5端口', '604800', '2592000'); //access token 7天; refreshToken 30天
    const WX_S = array("3", '微信小程序', '604800', '2592000'); //access token 7天; refreshToken 30天
    const DD_S = array("4", '钉钉小程序', '604800', '2592000'); //access token 7天; refreshToken 30天
    const ANDROID = array("5", '安卓端口', '604800', '2592000'); //access token 7天; refreshToken 30天
    const IOS = array("6", '苹果端口', '604800', '2592000'); //access token 7天; refreshToken 30天

    function __construct()
    {
        $this->EnumTypes = array(self::PC, self::H5, self::WX_S, self::DD_S, self::ANDROID, self::IOS);
    }
}

//用户角色
class WebRole extends TPEnum
{
    const Manage = array("1", '管理员', '1');
    const Customer = array("2", '客户', '2');
    const Salesman = array("3", '业务员', '3');
    const BusinessS = array("4", '业务组长', '4');
    const manager = array("5", '业务经理', '5');
    const market = array("6", '市场部经理', '6');



    function __construct()
    {
        $this->EnumTypes = array(self::Manage,self::Customer,self::Salesman,self::BusinessS,self::manager,self::market);
    }
}

//错误代码
//1-01-02
//第一位，0，成功；1，系统错误；2，业务错误
//第二位，业务模块，系统模块00-基础方法，01-api安全验证，02-权限，03-验证码,04-用户,05-角色
//第二位，业务模块，业务模块
//第三位，数字
class ErrCode extends TPEnum
{
    const ErrCode_00000 = array('00000', '请求成功', 'SUCCESS');
    const ErrCode_10001 = array("10001", '系统异常', 'System Error');
    const ErrCode_10002 = array("10002", '缺少参数', 'Param Missing');
    const ErrCode_10003 = array("10003", '参数错误', 'Param Error');
    const ErrCode_10004 = array("10004", '数据异常', 'SQL Eexcute Error');
    const ErrCode_10005 = array("10005", '服务器部署中，请稍后再试', 'SERVER DEPLOYMENT IN PROGRESS');
    const ErrCode_10101 = array("10101", '请求过期', 'Request Expired');
    const ErrCode_10102 = array("10102", 'Token无效', 'Token Invalid');
    const ErrCode_10103 = array("10103", 'Token过期', 'Token Expired');
    const ErrCode_10104 = array("10104", '异地登陆', 'Login in Other Place');
    const ErrCode_10105 = array("10105", '短时间内请求次数过多', 'Request Times Limit');
    const ErrCode_10006 = array("10006", '图片不存在,请上传', 'Image does not exist, please upload');
    const ErrCode_10007 = array("10007", '文件不存在,请上传', 'File Not Found');
    const ErrCode_10008 = array("10008", '文件类型不允许', 'Not allow');
    const ErrCode_10009 = array("10009", '上传的图片超出允许大小', 'The uploaded image is too large to exceed 20m');
    const ErrCode_10301 = array("10301", '验证码不正确或已过期', '');
    const ErrCode_10302 = array("10302", '验证码发送失败', '');
    const ErrCode_10401 = array("10401", '无效用户', 'Invalid User');
    const ErrCode_10402 = array("10402", '账号或密码错误', 'Usercode Error or Password Error');
    const ErrCode_10403 = array("10403", '用户不存在', 'User Not Found');
    const ErrCode_10404 = array("10404", '当前无权限', 'User No Permission');
    const ErrCode_10405 = array("10405", '账号名不能重复', 'Usercode Cannot Be Repeated');    
    const ErrCode_10406 = array("10406", '原密码错误', 'Usercode Cannot Be Repeated');
    const ErrCode_10407 = array("10407", '两次密码输入不一致', 'Usercode Cannot Be Repeated');
    const ErrCode_10501 = array("10501", '角色名不能重复', 'Name Cannot Be Repeated');
    const ErrCode_10502 = array("10502", '当前角色有使用账户不能删除', 'Role Cannot Be Deleted');
    const ErrCode_10503 = array("10503", '超级管理员不能被删除', 'Super Administrator Cannot Be Deleted');
    const ErrCode_10504 = array("10504", '请输入正确的邮箱', '');
    const ErrCode_10505 = array("10504", '请输入正确的手机号', '');
    const ErrCode_10012 = array("10012", 'Redis连接错误!', 'Redis error');
    const ErrCode_10601 = array("10601", '操作失败', 'Super Administrator Cannot Be Deleted');
    const ErrCode_10602 = array("10602", '无效的数量', 'Super Administrator Cannot Be Deleted');
    const ErrCode_10603 = array("10603", '花型编号不能重复', 'Super Administrator Cannot Be Deleted');
    const ErrCode_10701 = array("10701", '你不能这样操作!', 'Super Administrator Cannot Be Deleted');
    const ErrCode_10702 = array("10702", '审核已结束!', 'Super Administrator Cannot Be Deleted');
    const ErrCode_10703 = array("10703", '审核已是最初状态!', 'Super Administrator Cannot Be Deleted');
    const ErrCode_10704 = array("10704", '无效订单数据', '');
    const ErrCode_10801 = array("10704", '无当前花型', '');
    const ErrCode_10802 = array("10802", '订单已废除', '');
    const ErrCode_10803 = array("10803", '库存不足', '');
    const ErrCode_10901 = array("10901", '无效的状态', '');
    const ErrCode_10902 = array("10902", '没有数据', '');
    const ErrCode_10903 = array("10903", '商品库存不足', '');
    const ErrCode_10904 = array("10904", '邮箱不能重复', '');
    const ErrCode_10905 = array("10905", '请上传zip文件', '');
    const ErrCode_10906 = array("10906", '该员工有下单,无法禁用和删除', '');
    const ErrCode_10907 = array("10907", '请输入正确的封板大区域(洲编号)', '');
    const ErrCode_11001 = array("11001", '文件不可写', '');
    const ErrCode_11002 = array("11002", '分片信息错误', '');
    const ErrCode_11004 = array("11004", '图片获取失败', '');
    const ErrCode_11005 = array("11005", '密码已过期,请尽快修改密码!', '');
    const ErrCode_12000 = array("12000", '系统异常，请联系管理员', '');




    function __construct()
    {
        $this->EnumTypes = array(
            self::ErrCode_00000, self::ErrCode_10001, self::ErrCode_10002, self::ErrCode_10003, self::ErrCode_10004,self::ErrCode_10006,
            self::ErrCode_10101, self::ErrCode_10102, self::ErrCode_10103, self::ErrCode_10104, self::ErrCode_10105,
            self::ErrCode_10301, self::ErrCode_10302,
            self::ErrCode_00000, self::ErrCode_10001, self::ErrCode_10002, self::ErrCode_10003, self::ErrCode_10004,
            self::ErrCode_10101, self::ErrCode_10102, self::ErrCode_10103, self::ErrCode_10104, self::ErrCode_10105, self::ErrCode_10008, self::ErrCode_10009,
            self::ErrCode_10301, self::ErrCode_10302, self::ErrCode_10006, self::ErrCode_10007,
            self::ErrCode_10401, self::ErrCode_10402, self::ErrCode_10403, self::ErrCode_10404, self::ErrCode_10405,self::ErrCode_10406,self::ErrCode_10407,
            self::ErrCode_10005,self::ErrCode_10501,self::ErrCode_10502,self::ErrCode_10503,
            self::ErrCode_10005,self::ErrCode_10501,self::ErrCode_10502,self::ErrCode_10503,self::ErrCode_10504, self::ErrCode_10505,
            self::ErrCode_10601,self::ErrCode_10602, self::ErrCode_10012,self::ErrCode_10603,
            self::ErrCode_10701,self::ErrCode_10702,self::ErrCode_10703,self::ErrCode_10704, self::ErrCode_10801,self::ErrCode_10802,self::ErrCode_10803,
            self::ErrCode_10901,self::ErrCode_10902, self::ErrCode_10903 , self::ErrCode_10904,self::ErrCode_10905,self::ErrCode_10906,self::ErrCode_10907,
            self::ErrCode_11001,self::ErrCode_11002,self::ErrCode_11004,self::ErrCode_11005,self::ErrCode_12000
        );
    }
}

//系统配置type
class DicType extends TPEnum
{
    const WEBINFO = array('webInfo');
    const SYSTEMINFO = array('systemInfo');

    function __construct()
    {
        $this->EnumTypes = array(self::WEBINFO,self::SYSTEMINFO);
    }
}

//系统配置key
class DicKey extends TPEnum
{
    const WEBTITLE = array('webInfo', 'webtitle');
    const KEYWORDS = array('webInfo','keywords');
    const DESCRIPTION = array('webInfo','description');
    const COMPANY = array('webInfo','company');
    const ONLINE = array('systemInfo','online');

    function __construct()
    {
        $this->EnumTypes = array(self::WEBTITLE,self::KEYWORDS,self::DESCRIPTION,self::COMPANY,self::ONLINE);
    }
}



class SubmitStatus extends TPEnum
{
    const zero  = array('0','未提交');
    const First  = array('1','客户已提交');
    const second  = array('2','业务员已提交');
    const third  = array('3','业务组长(业务经理)已审核');

    function __construct()
    {
        $this->EnumTypes = array(self::zero,self::First,self::second,self::third);
    }
}
